package com.buydeem.composite;

/**
 * 组合模式客户端代码
 * @author zengchao
 * @date 2022-05-08 12:28:46
 */
public class App {
    public static void main(String[] args) {
        //公司
        Component company = new Composite("公司");
        //产品部
        Component department1 = new Composite("产品部");
        company.add(department1);
        //水机组
        Component group1 = new Composite("水机组");
        group1.add(new Leaf("小明",1000));
        group1.add(new Leaf("小白",1000));
        department1.add(group1);
        //食品组
        Component group2 = new Composite("食品组");
        group2.add(new Leaf("小黑",2000));
        department1.add(group2);
        //养生壶组
        Component group3 = new Composite("养生壶组");
        group3.add(new Leaf("小花",2000));
        department1.add(group3);

        //技术部
        Component department2 = new Composite("技术部");
        company.add(department2);
        //前端组
        Component group4 = new Composite("前端组");
        group4.add(new Leaf("张三",2000));
        department2.add(group4);
        //后端组
        Component group5 = new Composite("后端组");
        group5.add(new Leaf("李四",2000));
        group5.add(new Leaf("王麻子",2000));
        department2.add(group5);
        //测试组
        Component group6 = new Composite("测试组");
        group6.add(new Leaf("王五",2000));
        department2.add(group6);

        //CEO
        company.add(new Leaf("CEO",10000));

        //打印
        company.print(0);
        //计算薪水
        Integer salary = company.getSalary();
        System.out.println(salary);
    }
}
